<template>
	<view class="content">
		<list v-if="show" :list="list" @detail="detail"></list>
		<wanl-empty v-if="!list.length"></wanl-empty>
		<view class="btn" @click="add()">添加分类</view>
	</view>
</template>

<script>
	import {
		getShopGoodsCategory,
	} from '@/API/business.js'
	import list from '../components/category/list'
	export default {
		components: {
			list
		},
		data() {
			return {
				show: false,
				list: [],
			}
		},
		onShow() {
			this.getList()
		},
		methods: {
			getList(init) {
				this.show = false
				getShopGoodsCategory().then(res => {
					this.list = res.data
					this.show = true
				})
			},
			add(pid = 0) {
				uni.navigateTo({
					url: '/pages/business/category/detail?pid=' + pid
				})
			},
			detail(item) {
				uni.navigateTo({
					url: '/pages/business/category/detail?data=' + JSON.stringify(item)
				})
			}
		}
	}
</script>

<style lang="less" scoped>
	.content {
		padding: 20rpx;


		.btn {
			position: fixed;
			bottom: 30rpx;
			left: 0;
			right: 0;
			margin: auto;
			width: 610rpx;
			height: 92rpx;
			line-height: 92rpx;
			text-align: center;
			background: linear-gradient(90deg, #DD551B, #F49355);
			border-radius: 46rpx;
			font-family: Source Han Sans CN;
			font-weight: 500;
			font-size: 34rpx;
			color: #FFFFFF;
		}
	}
</style>